<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class UploadForm extends CWidget {
    
    public $postUrl = '/help/upload';
//    
//    function __construct() {
//       $this->languageUrl = Common::getOptionValue('languagesupport','Url');
//    }
    
    public function run() { 
        $ourscript = '$("#photoimg").live("change", function(){$("#preview").html("");$("#preview").html("wating..."); $("#imageform").ajaxForm({target: "#preview"}).submit();});';
        Yii::app()->clientScript->registerScript('ImgUpload',$ourscript,CClientScript::POS_READY);
        Yii::app()->clientScript->registerScriptFile("/js/jqueryform.js", CClientScript::POS_HEAD);
        echo CHtml::beginForm($this->postUrl, 'post', array ( 'id'=>"imageform", 'enctype'=>"multipart/form-data"));
        echo CHtml::label('Upload image', 'upload');
        echo CHtml::fileField('photoimg','',array('id'=>'photoimg'));
        echo CHtml::endForm();
        echo "<div id='preview'></div>";
    }
 
}

?>